home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 …SCII & the Runetime Code / ADC Developer CD (1992-07) (''Butch ASCII And The Runtime Code'')_iso / Dev.CD 199207.iso / Tools & Apps / Graphics & Imaging / Ultra Dragging 1.0ß1 / UNothing.p < prev    next >
Encoding:
Text File  |  1991-04-08  |  7.4 KB  |  261 lines  |  [TEXT/MPS ]

  1. { UNothing.p}
  2. { Copyright © 1990, 1991 by Apple Computer, Inc. All rights reserved.}
  3.  
  4. {    Original code by: Kurt Schmucker (KJS).
  5.     Modified by: Geoff Pascoe (GAP).
  6.     
  7.     Change List:
  8.  
  9.         ddmmyy
  10.     GAP 060990    Modified USES when changing from Lightspeed Pascal to MPW.
  11.     GAP 181290    Added more comments.
  12.     GAP 110190  TTrackingView is now a subclass of TView.
  13.     GAP 110190  TCGridView is now TCGridView1 and a subclass of TReleifGridView.
  14.     GAP 110190  TCGridView1.GetComponentTracker and TCGridView1.PlaceComponent
  15.                 are no longer overrides.
  16.     GAP 110190  Cleaned up some comments.
  17.     GAP 110191    Added sense parameter to PlaceComponent methods to indicate whether this
  18.                 is a placement (TRUE) or an undo of a placement (FALSE).
  19.     GAP 110191    Changed PlaceComponent methods from FUNCTIONS to PROCEDURES.
  20.     GAP    110191    Removed fOldComponentNumber instance variable from TComponentTracker
  21.                 and put it in TCGridView1.
  22.     GAP    170191    Changed IComponentTracker to take a generic TView as its first argument
  23.                 as apposed to a TTrackingView.
  24.     GAP    170191    Changed TComponentTracker instance variable fTrackingView:TTrackingView to
  25.                 fTrackingView:TView.
  26.     GAP    180191    Added TCGridView2 class.
  27.     GAP    180191    Removed argument from ICGridView1 and ICGridView2.
  28.     GAP    180191    Removed kCGridWindowResID and dded kCGridWindow1ResID
  29.                 and kCGridWindow2ResID.
  30.     GAP    250191    Added new data type, ComponentPlacementSense, that is now the type
  31.                 of the sense paramater in PlaceComponent.
  32.     GAP    190291    Added fTrackingWindow instance variable to TComponentTracker.
  33.     GAP    020491    Massive changes for latest version using UIconDragging unit.
  34.  
  35.                 
  36.     End Change List. }
  37.  
  38. UNIT UNothing;
  39.  
  40. {    This program demonstrates how to track on the desktop from one view to another. }
  41.  
  42.  
  43. INTERFACE
  44.  
  45.  
  46.     USES
  47.     
  48.     {    Required for this unit's interface    }
  49.         Packages,
  50.         
  51.     {    MacApp    }
  52.         UMacApp,
  53.  
  54.     {    Standard MacApp Building Blocks    }
  55.         UPrinting,
  56.         UGridView,
  57.         
  58.     {    Other Building Blocks    }
  59.         UReliefGridView,
  60.         UOSBitmap,
  61.         UOSImage,
  62.         UIconDragging;
  63.  
  64.     CONST
  65.  
  66.     {    Signatures and Types    }
  67.         kSignature = 'SS01';
  68.         kFileType = 'SF01';
  69.  
  70.     {    CIcon Id's    }
  71.         kDaffy1Icon = 801;
  72.         kBugsIcon = 802;
  73.         kSylvesterIcon = 803;
  74.         kTweetyIcon = 804;
  75.         kDaffy2Icon = 805;
  76.         kDevilIcon = 806;
  77.         kFoghornIcon = 807;
  78.         kOscarIcon = 901;
  79.         kHobbsIcon = 902;
  80.         kCalvinIcon = 903;
  81.         kYinYangIcon = 904;
  82.         kMoofIcon = 905;
  83.  
  84.     {    View constants and id's    }
  85.         kLooneyWindow1ResID = 2001;
  86.         kLooneyWindow2ResID = 2002;
  87.         kLooneyViewID = 'lgrd';
  88.  
  89.     {    Miscellaneous constants    }
  90.         kNumberOfRows = 5;
  91.         kNumberOfColumns = 2;
  92.         kMaxLooneys = kNumberOfRows * kNumberOfColumns;
  93.  
  94.     TYPE
  95.  
  96.         Looney = CIconHandle;
  97.  
  98.         LooneyNumber = IconNumber;
  99.  
  100.         LooneyRange = 1..kMaxLooneys;
  101.  
  102.         LooneyPlacementSense = IconPlacementSense;
  103.  
  104.  
  105.     {    The LooneyApplication    }
  106.  
  107.         TLooneyApplication = OBJECT(TApplication)
  108.  
  109.                 PROCEDURE TLooneyApplication.ILooneyApplication (itsMainFileType: OSType);
  110.  
  111.                 PROCEDURE TLooneyApplication.Fields (PROCEDURE DoToField (fieldName: Str255;
  112.                                                                           fieldAddr: Ptr;
  113.                                                                           fieldType: INTEGER));
  114.                 OVERRIDE;
  115.  
  116.                 FUNCTION TLooneyApplication.DoMakeDocument (itsCmdNumber: cmdNumber): TDocument;
  117.                 OVERRIDE;
  118.  
  119.             END; {TLooneyApplication}
  120.  
  121.  
  122.     {    The TLooneyDocument controls a TLooneyView1 or TLooneyView2.  Both
  123.         are needed to demonstrate that icons can be dragged between two
  124.         views not of the same class.                                            }
  125.  
  126.         TLooneyDocument = OBJECT(TDocument)
  127.  
  128.                 PROCEDURE TLooneyDocument.ILooneyDocument;
  129.  
  130.                 PROCEDURE TLooneyDocument.Fields (PROCEDURE DoToField (fieldName: Str255;
  131.                                                                        fieldAddr: Ptr;
  132.                                                                        fieldType: INTEGER));
  133.                 OVERRIDE;
  134.  
  135.                 PROCEDURE TLooneyDocument.DoMakeViews (forPrinting: BOOLEAN);
  136.                 OVERRIDE;
  137.  
  138.             END; {TLooneyDocument}
  139.  
  140.  
  141.     {    A TLooneyView1 ia a ReliefGridView that displays icons/Looneys
  142.         and allows moving tracking on desktop and between views.  It starts
  143.         up displaying Looney Tunes characters but is otherwise identical to
  144.         TLooneyView2.                                                            }
  145.  
  146.         TLooneyView1 = OBJECT(TReliefGridView)
  147.  
  148.                 fOldLooneyNumber: LooneyNumber;                            { The Looney we replaced in a PlaceLooney- used for undo.    }
  149.                 fLooneyNumbers: ARRAY[LooneyRange] OF LooneyNumber;        { The Looney numbers for Looneys in this view.                }
  150.  
  151.                 PROCEDURE TLooneyView1.ILooneyView1;
  152.  
  153.                 PROCEDURE TLooneyView1.Fields (PROCEDURE DoToField (fieldName: Str255;
  154.                                                                     fieldAddr: Ptr;
  155.                                                                     fieldType: INTEGER));
  156.                 OVERRIDE;
  157.  
  158.                 FUNCTION TLooneyView1.DoMouseCommand (VAR theMouse: Point;
  159.                                                       VAR info: EventInfo;
  160.                                                       VAR hysteresis: Point): TCommand;
  161.                 OVERRIDE;
  162.  
  163.                 PROCEDURE TLooneyView1.DrawCell (aCell: GridCell; aQDRect: Rect);
  164.                 OVERRIDE;
  165.  
  166.                 PROCEDURE TLooneyView1.PlotMyIcon (aCell: GridCell; aQDRect: Rect);
  167.  
  168.                 PROCEDURE TLooneyView1.PlotMyText (aCell: GridCell; aQDRect: Rect);
  169.  
  170.                 FUNCTION TLooneyView1.GetIndexFromCell (aCell: GridCell): INTEGER;
  171.  
  172.                 FUNCTION TLooneyView1.GeTLooneyPlacer (aLooneyNumber: LooneyNumber;
  173.                                                        offset: Point): TLooneyPlacer;
  174.  
  175.                 PROCEDURE TLooneyView1.PlaceLooney (aLooneyNumber: LooneyNumber;
  176.                                                     aVPoint: VPoint;
  177.                                                     sense: LooneyPlacementSense);
  178.  
  179.             END; {TLooneyView1}
  180.  
  181.  
  182.     {    A TLooneyView1 ia a ReliefGridView that displays icons/Looneys
  183.         and allows moving tracking on desktop and between views.  It starts
  184.         up displaying other cartoon characters but is otherwise identical to
  185.         TLooneyView1.                                                            }
  186.  
  187.         TLooneyView2 = OBJECT(TReliefGridView)
  188.  
  189.                 fOldLooneyNumber: LooneyNumber;                            { The Looney we replaced in a PlaceLooney- used for undo.    }
  190.                 fLooneyNumbers: ARRAY[LooneyRange] OF LooneyNumber;        { The Looney numbers for Looneys in this view.                }
  191.  
  192.                 PROCEDURE TLooneyView2.ILooneyView2;
  193.  
  194.                 PROCEDURE TLooneyView2.Fields (PROCEDURE DoToField (fieldName: Str255;
  195.                                                                     fieldAddr: Ptr;
  196.                                                                     fieldType: INTEGER));
  197.                 OVERRIDE;
  198.  
  199.                 FUNCTION TLooneyView2.DoMouseCommand (VAR theMouse: Point;
  200.                                                       VAR info: EventInfo;
  201.                                                       VAR hysteresis: Point): TCommand;
  202.                 OVERRIDE;
  203.  
  204.                 PROCEDURE TLooneyView2.DrawCell (aCell: GridCell; aQDRect: Rect);
  205.                 OVERRIDE;
  206.  
  207.                 PROCEDURE TLooneyView2.PlotMyIcon (aCell: GridCell; aQDRect: Rect);
  208.  
  209.                 PROCEDURE TLooneyView2.PlotMyText (aCell: GridCell; aQDRect: Rect);
  210.  
  211.                 FUNCTION TLooneyView2.GetIndexFromCell (aCell: GridCell): INTEGER;
  212.  
  213.                 FUNCTION TLooneyView2.GeTLooneyPlacer (aLooneyNumber: LooneyNumber;
  214.                                                        offset: Point): TLooneyPlacer;
  215.  
  216.                 PROCEDURE TLooneyView2.PlaceLooney (aLooneyNumber: LooneyNumber;
  217.                                                     aVPoint: VPoint;
  218.                                                     sense: LooneyPlacementSense);
  219.  
  220.             END; {TLooneyView2}
  221.  
  222.  
  223.     { Tracks a Looney and allows placement in TTrackingViews.    }
  224.  
  225.         TLooneyPlacer = OBJECT(TPlaceByNumber)
  226.  
  227.             PROCEDURE TLooneyPlacer.ILooneyPlacer (aTrackingView: TView;
  228.                                                    offset: Point;
  229.                                                    aLooneyNumber: LooneyNumber);
  230.  
  231.             PROCEDURE TLooneyPlacer.Fields (PROCEDURE DoToField (fieldName: Str255;
  232.                                                                  fieldAddr: Ptr;
  233.                                                                  fieldType: integer));
  234.             OVERRIDE;
  235.  
  236.         {    Actions    }
  237.             PROCEDURE TLooneyPlacer.DoIt;
  238.             OVERRIDE;
  239.  
  240.             PROCEDURE TLooneyPlacer.UndoIt;
  241.             OVERRIDE;
  242.  
  243.             PROCEDURE TLooneyPlacer.RedoIt;
  244.             OVERRIDE;
  245.  
  246.         END; {TLooneyPlacer}
  247.  
  248.  
  249. { :::::::::::::::::::::::   Globals    ::::::::::::::::::::::: }
  250.  
  251.  
  252.     VAR
  253.         gLooneyApplication: TLooneyApplication;    { Global representing the only TLooneyApplication object    }
  254.         gLooneyPaletteFlag: BOOLEAN;                { Determines with of two palettes is created- it alternates }
  255.         
  256.  
  257. IMPLEMENTATION
  258.  
  259.     {$I $$Shell(SrcApp)UNothing.inc1.p}
  260.  
  261. END. {UNothing}